﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Linq;
using Spore.Validator;

namespace Client
{
    public partial class FormVipDeferReqLook : BasePopForm
    {
        List<QunYing.Model.VipServices> services;
        List<QunYing.Model.VipRank> vipRank;
        QunYing.BLL.VipPayOrder bll_VipPayOrder= new QunYing.BLL.VipPayOrder();
      
        public QunYing.Model.VipPayOrder VipPayOrder
        {
            get;
            private set;
        }



        public FormVipDeferReqLook()
        {
            InitializeComponent();
            this.services = (new QunYing.BLL.VipServices()).GetModelList(string.Empty);
            this.vipRank = (new QunYing.BLL.VipRank()).GetModelList(string.Empty);
          //  this.cbe_会员级别.SelectedIndexChanged += new EventHandler(cbe_会员级别_SelectedIndexChanged);
            this.FormValidator.SetControlValitors(this.cbe_会员级别, ValidatorDefaults.NotNull);
            this.FormValidator.SetControlValitors(this.det_到期时间, ValidatorDefaults.NotNull);
            this.FormValidator.SetControlValitors(this.txt_缴费金额, ValidatorDefaults.Integer);
           // this.NecessaryRemark(this.cbe_会员级别, this.det_到期时间, this.txt_缴费金额, this.txt_服务项);

        }

       

       

        public void BindData(QunYing.Model.VipPayOrder payOrder)
        {
            this.lbl_会员卡号.Text = payOrder.会员卡号;
            this.lbl_经销商.Text = payOrder.经销商ID;
            this.lbl_级别.Text = payOrder.会员原级别;
            this.lbl_到期时间.Text = payOrder.原到期时间;
            this.cbe_会员级别.Text = payOrder.会员新级别;
            this.det_到期时间.DateTime = payOrder.新到期时间;
            this.txt_服务项.BeginUpdate();
            this.txt_服务项.Items.Clear();
            string[] strs = vipRank.First((v) => { return v.等级名称 == cbe_会员级别.Text; }).基本服务条款.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            foreach (var v in strs)
            {
                var temp = services.First((vv) => { return vv.ID.ToString() == v; });
                this.txt_服务项.Items.Add(temp, true);
            }
            this.txt_服务项.EndUpdate();
            this.txt_服务项.Enabled = false;
            this.txt_缴费金额.Text = payOrder.缴费金额.ToString();
            this.txt_缴费金额.Properties.ReadOnly = true;
            this.cbe_会员级别.Properties.ReadOnly = true;
            this.det_到期时间.Properties.ReadOnly = true;

            
        }



        private void sharpButton2_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.No;
        }
        
    }
}